Discover delete duplicate records in sql, include the articles, news, trends, analysis and practical advice about delete duplicate records in sql on alibabacloud.com
Method 1 Delete yourtable where [id] not in ( Select MAX ([id]) from yourtable Group by (name + Valu) E) Method 2 Delete a from table a LEFT join ( Select (ID) from table GROUP by Name,value ) b on A.id=b.id Where b.id is null Query and delete duplicate records
Share the following method of deleting duplicate records in a database with an SQL statement.For example, there is now a person table (table name: peosons)If you want to name, ID, address, the three fields exactly the same record querySelect p1.* from Persons p1,persons P2 where p1.idCan achieve the above effect.Several SQL
SQL Duplicate record query
1, look for redundant records in the table, duplicate records are based on a single field (Peopleid) to judge
SELECT * from people
where Peopleid to (select Peopleid from People GROUP by Peopleid have count (Peopleid) > 1)
Case Two
Title)
Note: The maximum ID record is displayed here.
Ii. Delete duplicate records
1. Delete All Repeated Records (use with caution)
?
1
Delete table Where repeated field In (Select repeated field From Table Group By repeated
Search for records with all repeated titles:
SELECT * FROM t_info a WHERE ((SELECT COUNT(*) FROM t_info WHERE Title = a.Title) > 1) ORDER BY Title DESC
1. Search for duplicate records
1. Search for all Repeated Records
Select * From table Where repeated field In (Select repeated field From Table Group By repeated fiel
There are many ways for SQLServer to search for and delete duplicate records in tables. Below I will list several commonly used SQL statements with good performance. If you need them, please refer to them.
There are many ways for SQL Server to find and
Original post address: http://www.cnblogs.com/phpliu/archive/2010/06/21/1761726.html
For example:ID name value1 A PP2 A PP3 B III4 B PP5 B PP6 c pp7 c pp8 C IIIID is the primary keyThis result is required.ID name value1 A PP3 B III4 B PP6 c pp8 C III
Method 1Delete yourtableWhere [ID] Not in (Select max ([ID]) from yourtableGroup by (name + value ))
Method 2DeleteFrom table a left join (Select (ID) from Table group by name, Value) B on A. ID = B. IDWhere B. ID is null
The SQL statement used to query multiple fields, query multiple tables, and delete duplicate records.
SQL repeat record Query
1. Search for redundant duplicate records in the Table.
There are often repeated records in the database. sometimes I want to query duplicate records and display them, and sometimes I want to delete them. next I will introduce how to delete and query duplicate
SQL statement to query duplicate records and delete Repeated Records Search for records with all repeated titles:
Select * From t_info A where (select count (*) from t_info where title = A. Title)> 1) Order by title DESC
I.
Searc
Quickly delete duplicate records in SQL Server 2006-07-17 21:53:15Category: SQL Server
Developer's Nightmare-delete duplicate recordsPresumably, every developer has had
Nightmare for Developers--delete duplicate records Presumably every developer has had a similar experience, and when querying or counting the database, the query and statistic results are inaccurate due to duplicate records in the table. The solution to this problem is to
For example, there is a personnel table (table name: peosons)If you want to query records whose names, ID card numbers, and addresses are identical
Select p1. * from persons p1, persons p2 where p1.id
The above results can be achieved.
Several SQL statements used to delete Repeated Records
1. Use the rowid Method
2. U
How to quickly delete duplicate records in SQL Server
Developer nightmare-delete Repeated Records
Presumably, every developer has had a similar experience. When querying or collecting statistics on the database, the query an
server| Repeat | Recurring nightmare for Developers--delete duplicate records
Presumably every developer has had a similar experience, and when querying or counting the database, the query and statistic results are inaccurate due to duplicate records in the table. The solut
SQL statements Delete duplicate records and retain only one record.
Copy codeThe Code is as follows:Delete WeiBoTopics where Id in (select max (Id) from WeiBoTopics group by WeiBoId, Title having COUNT (*)> 1 );
SQL: delete
Developer nightmare-delete Repeated Records
Presumably, every developer has had a similar experience. When querying or collecting statistics on the database, the query and statistics results may be inaccurate due to repeated records in the table. The solution to this problem is to delete these
Developer nightmare-delete Repeated RecordsPresumably, every developer has had a similar experience. When querying or collecting statistics on the database, the query and statistics results may be inaccurate due to repeated records in the table. The solution to this problem is to delete these duplicate
1. Find all duplicate records
The code is as follows
Copy Code
SELECT * FROM table Where repeat field in (Select repeating field from table Group by repeating field having Count (*) >1)
2. Filter duplicate records (show only one)
The code is as follows
Copy Code
how much
in thousands of records, there are some same records, how can you use SQL statements, delete duplicates1, look for redundant records in the table, duplicate records
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.